home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / gui / invite_friends.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2008-10-13  |  9.8 KB  |  208 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. from anylists import AnyRow
  5. from pref import prefcontrols
  6. from uberwidgets.PrefPanel import PrefPanel
  7. from common import profile as p
  8. from gui.anylists import AnyList
  9. from util.observe import ObservableList
  10. from util.callbacks import callsback
  11. import wx
  12.  
  13. class StaticEmailRow(AnyRow):
  14.     checkbox_border = 3
  15.     row_height = 20
  16.     image_offset = (6, 0)
  17.     
  18.     def __init__(self, *a, **k):
  19.         AnyRow.__init__(self, *a, **k)
  20.  
  21.     
  22.     def PopulateControls(self, account):
  23.         self.checkbox.Value = True
  24.         self.text = self.data[1]
  25.  
  26.     
  27.     def image(self):
  28.         return self.data[0]
  29.  
  30.     image = property(image)
  31.     
  32.     def on_right_up(self, *a, **k):
  33.         pass
  34.  
  35.  
  36.  
  37. def f_f(a, b):
  38.     
  39.     def factory(*args):
  40.         return a(b(*args))
  41.  
  42.     
  43.     factory.__repr__ = lambda : '<factory composing %(a)r with %(b)s>' % locals()
  44.     return factory
  45.  
  46. pen_f = f_f(wx.Pen, wx.Color)
  47. brush_f = f_f(wx.Brush, wx.Color)
  48.  
  49. def pen_f_f(*a):
  50.     return (lambda : pen_f(*a))
  51.  
  52.  
  53. def brush_f_f(*a):
  54.     return (lambda : f_f(wx.Brush, wx.Color)(*a))
  55.  
  56. webmail_types = frozenset(('gmail', 'ymail', 'aolmail', 'hotmail'))
  57. TIME_UNTIL_SPAM = 604800
  58.  
  59. def do_user_initiated_check():
  60.     make_invite_diag(background = False, success = dialog_closed_callback)
  61.  
  62.  
  63. def do_background_check():
  64.     pref = pref
  65.     setpref = setpref
  66.     import common
  67.     time = time
  68.     import time
  69.     invite_times = pref('usertrack.invite.dialog.results', type = dict, default = { })
  70.     if invite_times:
  71.         return None
  72.     
  73.     if not any((lambda .0: for e in .0:
  74. e.protocol in webmail_types)(p.emailaccounts[:])):
  75.         return None
  76.     
  77.     first_online = pref('usertrack.firstknownonline', type = int, default = -1)
  78.     if not first_online > 0:
  79.         setpref('usertrack.firstknownonline', int(time()))
  80.         return None
  81.     elif int(time()) - first_online < 604800:
  82.         return None
  83.     else:
  84.         make_invite_diag(background = True, success = dialog_closed_callback)
  85.  
  86.  
  87. def dialog_closed_callback(result):
  88.     S = Storage
  89.     import util
  90.     time = time
  91.     import time
  92.     pref = pref
  93.     setpref = setpref
  94.     import common
  95.     result = S(result)
  96.     invite_times = pref('usertrack.invite.dialog.results', type = dict, default = { })
  97.     num_email_accts = len(p.emailaccounts)
  98.     num_webmail_accts = []([ e.protocol in webmail_types for e in p.emailaccounts[:] ])
  99.     track_data = dict(accts = len(result.accts), web_accts = num_webmail_accts, email_accts = num_email_accts, background = result.background, send = result.send)
  100.     num_not_triggered = sum((lambda .0: for t in .0:
  101. t.get('background', False))(invite_times.values()))
  102.  
  103.  
  104. def make_invite_diag(background = False, callback = None):
  105.     f = wx.Dialog(None)
  106.     f.Sizer = wx.BoxSizer(wx.VERTICAL)
  107.     p1 = InvitePanel(f)
  108.     
  109.     def handle_invite_done(e):
  110.         if e.EventType in wx.EVT_BUTTON:
  111.             print 'send was hit'
  112.             (name, accts) = p1.info()
  113.             if not name:
  114.                 return wx.MessageBox('Please enter your name so that ...\n will know from whom the invites were sent.', 'Please enter your name.')
  115.             
  116.             callback.success(dict(name = name, accts = accts, background = background, send = True))
  117.         elif e.EventType in wx.EVT_CLOSE:
  118.             (name, accts) = p1.info()
  119.             callback.success(dict(name = name, accts = accts, background = background, send = False))
  120.         
  121.         f.Show(False)
  122.         f.Destroy()
  123.  
  124.     f.Bind(wx.EVT_CLOSE, handle_invite_done)
  125.     f.Bind(wx.EVT_BUTTON, handle_invite_done)
  126.     f.Sizer.Add(p1, 1, wx.EXPAND)
  127.     p1.Layout()
  128.     f.Layout()
  129.     f.Fit()
  130.     f.SetMinSize(f.GetSize())
  131.     f.Show()
  132.     return f
  133.  
  134. make_invite_diag = callsback(make_invite_diag)
  135.  
  136. class InvitePanel(wx.Panel):
  137.     
  138.     def __init__(self, *a, **k):
  139.         if k.get('name') is not None:
  140.             k['name'] = 'Invite Panel'
  141.         
  142.         wx.Panel.__init__(self, *a, **k)
  143.         accounts = _[1]
  144.         data = []
  145.         for acct in accounts:
  146.             data.append((ico, acct.display_name, acct.protocol, acct.name, acct._decryptedpw()))
  147.         
  148.         self.data = data
  149.         self.Construct()
  150.         self.Fonts()
  151.         self.Layout()
  152.  
  153.     
  154.     def Construct(self):
  155.         parent = self
  156.         self.line1 = wx.StaticText(parent, label = "We hope you've enjoyed using Digsby.", style = wx.TE_CENTER)
  157.         self.line2 = wx.StaticText(parent, label = 'Please show your support and invite your friends.', style = wx.TE_CENTER)
  158.         self.separator = wx.StaticLine(parent)
  159.         self.name_label = wx.StaticText(parent, label = 'Full Name: ')
  160.         self.name_text = wx.TextCtrl(parent)
  161.         self.acct_list = AnyList(parent, ObservableList(self.data), row_control = StaticEmailRow, multiselect = False, edit_buttons = None, draggable_items = False, style = 0, velocity = None)
  162.         self.acct_list.SetMinSize(wx.Size(-1, 104))
  163.         self.acct_panel = PrefPanel(parent, self.acct_list, 'Account')
  164.         
  165.         self.acct_panel._bg_brush = lambda : wx.Brush(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE))
  166.         
  167.         self.acct_panel._fg_pen = lambda : wx.Pen(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DSHADOW))
  168.         self.send_button = wx.Button(parent, wx.ID_OK, label = 'Send Invite!')
  169.         self.send_button.MoveAfterInTabOrder(self.name_text)
  170.  
  171.     
  172.     def info(self):
  173.         acct_list = self.acct_list
  174.         acct_list = [ acct_list[i] for i in xrange(len(acct_list)) ]
  175.         return ([], _[2])
  176.  
  177.     
  178.     def Fonts(self):
  179.         fnt1 = self.line1.Font
  180.         fnt1.SetPointSize(fnt1.GetPointSize() + 4)
  181.         fnt1.SetWeight(wx.FONTWEIGHT_BOLD)
  182.         self.line1.Font = fnt1
  183.         self.line2.Font = fnt1
  184.         fnt2 = self.name_label.Font
  185.         fnt2.SetPointSize(fnt2.GetPointSize() + 2)
  186.         self.name_label.Font = fnt2
  187.  
  188.     
  189.     def Layout(self):
  190.         self.Sizer = s1 = prefcontrols.VSizer()
  191.         s1.Add(self.line1, 0, wx.EXPAND | wx.ALL, 5)
  192.         s1.Add(self.line2, 0, wx.EXPAND | wx.ALL & ~(wx.TOP), 5)
  193.         s1.Add(self.separator, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, 6)
  194.         s2 = prefcontrols.HSizer()
  195.         s2.AddSpacer(6)
  196.         s2.Add(self.name_label, 0, wx.EXPAND)
  197.         s2.Add(self.name_text, 3, wx.EXPAND)
  198.         s2.AddSpacer(6)
  199.         s1.Add(s2, 0, wx.EXPAND | wx.ALL, 9)
  200.         s1.Add(self.acct_panel, 1, wx.EXPAND | wx.ALL & ~(wx.TOP), 15)
  201.         s3 = prefcontrols.HSizer()
  202.         s3.AddStretchSpacer(20)
  203.         s3.Add(self.send_button, 60, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL & ~(wx.TOP), 3)
  204.         s3.AddStretchSpacer(20)
  205.         s1.Add(s3, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.EXPAND | wx.BOTTOM, 6)
  206.  
  207.  
  208.